﻿<%@ Page Language="C#" MasterPageFile="~/Theme/Stander/Stander.master" AutoEventWireup="true" CodeFile="Regions.aspx.cs" Inherits="Media_Regions" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="MainView" runat="server">
<h2>区域列表</h2>
<asp:GridView ID="RegionGridView" DataKeyNames="Id" runat="server" CssClass="normal mouseOver" 
    DataSourceID="RegionsDataSource" AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField HeaderText="名称">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:HyperLink NavigateUrl='<%# Eval("Id", "~/Media/?regionId={0}") %>'
                    ID="HyperLink1" runat="server"><%# Eval("Name") %></asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="描述">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="3" 
                    runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField>
            <EditItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                    Text="更新"></asp:LinkButton>
                <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="取消"></asp:LinkButton>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="编辑"></asp:LinkButton>
                <asp:LinkButton ID="LinkButton2" runat="server" 
                    CausesValidation="False" CommandName="Delete" OnClientClick="deleteConfirm(event);" 
                    Text="删除"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<csla:CslaDataSource ID="RegionsDataSource" runat="server" 
    TypeName="Active.Core.Regions, Active.Core" OnDeleteObject="RegionsDataSource_DeleteObject"
    OnSelectObject="RegionsDataSource_SelectObject"
    OnUpdateObject="RegionsDataSource_UpdateObject" 
    TypeSupportsPaging="False" TypeSupportsSorting="False"></csla:CslaDataSource>
</asp:View>
<asp:View ID="AddRegionView" runat="server">
<h2>填写区域信息</h2>
<asp:DetailsView ID="RegionDetailsView" DataKeyNames="Id" runat="server" EnableViewState="false" 
    DefaultMode="Insert" DataSourceID="RegionDataSource" AutoGenerateRows="False">
    <Fields>
        <asp:BoundField DataField="Name" HeaderText="名称" SortExpression="Name" />
        <asp:TemplateField HeaderText="描述" SortExpression="Description">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:TextBox ID="TextBox1" TextMode="MultiLine" Rows="3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowInsertButton="true" 
            ShowCancelButton="false" InsertText="添加" ButtonType="Button" />
    </Fields>
</asp:DetailsView>
<csla:CslaDataSource ID="RegionDataSource" runat="server" 
    TypeName="Active.Core.Region, Active.Core"
    TypeSupportsPaging="False" TypeSupportsSorting="False" OnInsertObject="RegionDataSource_InsertObject"></csla:CslaDataSource>
</asp:View>
</asp:MultiView>
<p><asp:LinkButton ID="lbtnAddRegion" runat="server" OnClick="lbtnAddRegion_Click">添加区域</asp:LinkButton></p>
</asp:Content>

